﻿/**
 * @file		dd_arm.h
 * @brief		ARM driver
 * @note		None
 * @attention	None
 * 
 * <B><I>Copyright 2016 Socionext Inc.</I></B>
 */

/** @weakgroup dd_arm_overview
@{
	CM0 ARM Driver.<br>
@}*//* --- end of dd_arm_overview */

#ifndef _DD_ARM_H_
#define _DD_ARM_H_

/** @weakgroup dd_arm_definition
@{*/

/* CMSIS include */
#include "ARMCM0.h"

#include "typedef.h"

/*----------------------------------------------------------------------*/
/* Definition															*/
/*----------------------------------------------------------------------*/
/* Nothing Special */

/*----------------------------------------------------------------------*/
/* Enumeration															*/
/*----------------------------------------------------------------------*/
/* Nothing Special */

/*----------------------------------------------------------------------*/
/* Structure															*/
/*----------------------------------------------------------------------*/
/* Nothing Special */

/*----------------------------------------------------------------------*/
/* Global Data															*/
/*----------------------------------------------------------------------*/
/* Nothing Special */

/*----------------------------------------------------------------------*/
/* Macro																*/
/*----------------------------------------------------------------------*/
#define Dd_ARM_Critical_Section_Start()	{volatile uint32_t _r=__get_PRIMASK();__disable_irq();		/**< Critical Section Start */
#define Dd_ARM_Critical_Section_End()	__set_PRIMASK(_r);}											/**< Critical Section End */

#define Dd_ARM_Dmb_Pou()				__asm__ __volatile__ ("DMB 0xF")							/**< Data Memory Barrier */
#define Dd_ARM_Dsb_Pou()				__asm__ __volatile__ ("DSB 0xF")							/**< Data Synchronization Barrier */
#define Dd_ARM_Isb_Pou()				__asm__ __volatile__ ("ISB 0xF")							/**< Instruction Synchronization Barrier */

/* @} */	// dd_arm_definition group

/** @weakgroup dd_arm_api
@{*/
/*----------------------------------------------------------------------*/
/* Function																*/
/*----------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif

/**
Enable IRQ and Set program status included IRQ mask bit
@param[in]	sr		: program status included IRQ mask bit
*/
VOID Dd_ARM_EI(unsigned sr);

/**
Disable IRQ and Get program status included IRQ mask bit
@return		program status included IRQ mask bit.
*/
unsigned Dd_ARM_DI(VOID);


#ifdef __cplusplus
}
#endif

/* @} */	// dd_arm_api group

#endif	// _DD_ARM_H_

